<?php
include_once '../db_conecta_adodb.inc.php';
include_once '../function.inc.php';

$rs=sql("SELECT ID_SYS_NEWS,DT_DATE,CHR_TYPE,CHR_DESCRIPTION,INT_READ FROM u172676809_fcac.T_SYS_NEWS ORDER BY 2 desc","");
$return=array();
while($row=siguiente($rs)){
	//Tipo de Novedad
	switch ($row->CHR_TYPE){
		case 'o':
			$img='../img/symbol/ok.png';
			$typeTitle='Confirmaci&oacute;n';
			break;
		case 'w':
			$img='../img/symbol/pendiente.png';
			$typeTitle='Advertencia';
			break;
		case 'e':
			$img='../img/symbol/error.png';
			$typeTitle='Error';
			break;
		case 'i':
			$img='../img/symbol/information.png';
			$typeTitle='Informaci&oacute;n';
			break;
	}
	//Leido / No Leido
	if($row->INT_READ==0){
		$read='../img/panel/no_leido.png';
		$title='Marcar como Leido';
	}else{
		$read='../img/panel/leido.png';
		$title='Marcar como NO Leido';
	}

	$novedad=array("Leido"=>"<a onClick='ps(\"ajax.php\"+a(\"marcar_novedad\")+\"&id=".$row->ID_SYS_NEWS."&read=".$row->INT_READ."\",\"div-result\",\"\",\"div-img\",true);'><img src='".$read."' style='cursor:pointer;' class='tooltip' title='".$title."'/></a>",
					"Tipo"=>"<img src='".$img."' class='tooltip' title='".$typeTitle."'/>",
					"Fecha"=>date(dateTimeFromDBtoPick($row->DT_DATE,'es')),
					"Novedad"=>$row->CHR_DESCRIPTION,
					"Id"=>$row->ID_SYS_NEWS,
					"Read"=>$row->INT_READ
					);
	array_push($return, $novedad);
}
//$result=array($return);
echo json_encode($return);